{extend name="common/pop" /}
{block name="content"}

<div class="layui-form" style="margin-top:15px;width:90%;">
    <div class="layui-form-item">
        <label class="layui-form-label">配置分组</label>
        <div class="layui-input-block">
            {volist name="group" id="vo"}
            <input type="radio" name="group" value="{$vo.tag}" title="{$vo.name}" {if $key == 0}checked{/if}>
            {/volist}
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">配置类型</label>
        <div class="layui-input-block">
            <select name="type" id="">
                <option value=""></option>
                {volist name="html" id="h"}
                <option value="{$key}">{$h}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">配置名</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="title" placeholder="请输入" required>
        </div>
        <div class="layui-input-block j-form-tips">
            一般由中文组成，仅用于显示
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">配置标识</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="key" placeholder="请输入" required>
        </div>
        <div class="layui-input-block j-form-tips">
            由英文字母和下划线组成，如 <code>web_site_title</code>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">配置内容</label>
        <div class="layui-input-block">
            <textarea name="value" class="layui-textarea"></textarea>
        </div>
        <div class="layui-input-block j-form-tips">
            该配置的具体内容
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">配置项</label>
        <div class="layui-input-block">
            <textarea name="option" class="layui-textarea"></textarea>
        </div>
        <div class="layui-input-block j-form-tips">
            用于单选、多选、下拉、联动等类型
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">配置说明</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="tips" placeholder="请输入" required autocomplete="off">
        </div>
        <div class="layui-input-block j-form-tips">
            该配置的具体说明
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            <input type="number" class="layui-input" name="sort" placeholder="请输入" required value="0" autocomplete="off">
        </div>
    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="create">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script>
    layui.use(['layer','jquery','form'],function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery;

        form.render();


        form.on('submit(create)',function(data){
            var loading = layer.load();
            $.post('{:url("")}',data.field,function(r){
                layer.close(loading);
                if(r.code == 1){
                    layer.msg(r.msg);
                    close(1500,true);
                }else{
                    layer.msg(r.msg);
                }
            },'json')
        });
    })
</script>
{/block}

